<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>详情</title>

</head>
<body>
<!--    抽取公共头部-->
<div th:replace="share/common :: head"></div>
<!--导航-->
<!--    抽取公共导航-->
<div th:replace="share/common :: menu(20)"></div>

<!--顶部图片-->
<div class="m-bg-type_outer" style="width: 100%;height: 50%">
    <img src="../static/images/bg.jpg" alt="" class="ui m-bg image" style="width: 100%;height: 100%">
    <div class="m-bg-class_cover">
        <div class="ui container" style="position: relative ;bottom: -540px;">
            <h2 class="m-font-size-title-large" th:if="${blog!=null}" th:text="${blog.title}" align="center">Markdown编辑</h2>
            <div class="ui container" align="center">
                <div class="ui horizontal link list" align="center">
                    <div class="item">
       <div class="ui orange basic label" th:if="${blog!=null}" style="font-size: 7px" th:text="${#dates.format(blog.archives,'yyyy-mm')}">原创</div>
                    </div>
<!--                    <div class="item">-->
<!--                        <i class="user outline outline icon m-font-size-text-mini"></i>-->
<!--                        &lt;!&ndash;                        <a href="#" style="color: #ffffff;font-size: 18px" th:text="${blog.nickname}">oneStar</a>&ndash;&gt;-->
<!--                    </div>-->
                    <div class="item">
                        <i class="calendar icon m-font-size-text-mini"></i>
                        <span class="m-font-size-text-mini" th:if="${blog!=null}" th:text="${#dates.format(blog.createTime,'yyyy-MM-dd')}">2020-01-01</span>
                    </div>

<!--                <div class="item">-->
<!--                    <i class="clone icon m-font-size-text-mini"></i>-->
<!--                    &lt;!&ndash;                        <a href="#" target="_blank" style="color: #ffffff;font-size: 16px" th:text="${blog.typesName}">我的故事</a>&ndash;&gt;-->
<!--                </div>-->
                <div class="item">
                    <i class="eye icon m-font-size-text-mini"></i> <span class="m-font-size-text-mini"
                                                                         th:if="${blog!=null}" th:text="${blog.views}">2222</span>
                </div>
                <div class="item">
                    <i class="comment icon m-font-size-text-mini"></i>
                    <span class="m-font-size-text-mini" th:if="${blog!=null}" th:text="${blog.commentCount}">2222</span>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<!--中间内容-->
<div id="waypoint" class="m-margin- animated fadeIn">
    <div class="ui container m-opacity box-shadow-max">
        <!--内容-->
        <div class="ui attached padded segment">

<!--            </div>-->
            <!--中间主要内容部分-->
            <div th:if="${blog!=null}">
                <div id="content" class="typo  typo-selection js-toc-content m-padded-lr-responsive m-padded-tb-large"
                     th:utext="${blog.content}">

                </div>
            </div>


            <div class="ui horizontal divider">end</div>

<!--            <div th:if="${blog!=null&&blog.moneyOpen}">-->
<!--                <div class="ui center aligned basic segment">-->
<!--                    <button id="payButton" class="ui orange basic circular button">赞赏</button>-->
<!--                </div>-->
<!--                <div class="ui payQR flowing popup transition hidden">-->
<!--                    <div class="ui orange basic label">-->
<!--                        <div class="ui images" style="font-size: inherit !important;">-->
<!--                            <div class="image">-->
<!--                                <img src="../static/images/m-zfb.png" th:src="@{/images/m-zfb.png}" alt=""-->
<!--                                     class="ui rounded bordered image" style="width: 120px">-->
<!--                                <div>支付宝</div>-->
<!--                            </div>-->
<!--                            <div class="image">-->
<!--                                <img src="../static/images/m-xw.png" th:src="@{/images/m-wx.png}" alt=""-->
<!--                                     class="ui rounded bordered image" style="width: 120px">-->
<!--                                <div>微信</div>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->

        </div>

        <div id="goto" class="ui attached positive message">
            <!--博客信息-->
            <div class="ui middle aligned grid">
                <div class="nine wide column">
                    <ui class="list">
<!--                        <li>作者：<span>ONESTAR</span><a href="#" th:href="@{/about}" target="_blank">（联系作者）</a></li>-->
                        <li>版权声明：免责声明,以上内容源自网络，版权归原作者所有，如有侵犯您的原创版权请告知，我们将尽快删除相关内容！！！</li>
<!--                        <li>转载声明：如果是转载栈主转载的文章，请附上原文链接</li>-->
<!--                        <li>微信号：问题咨询添加作者微信二维码（微信号二维码见右边，欢迎添加）</li>-->
                    </ui>
                </div>
<!--                &lt;!&ndash;微信公众号&ndash;&gt;-->
<!--                <div class="seven wide column">-->
<!--                    <img src="../static/images/oneStar1.jpg" th:src="@{/images/wx.png}" alt=""-->
<!--                         class="ui right floated rounded bordered image" style="width: 250px">-->
<!--                </div>-->
            </div>
        </div>
        <!--        评论区域-->
        <div class="ui bottom attached segment">
            <!--评论区域列表-->
            <div id="comment-container" class="ui red segment">
                <div th:fragment="commentList">
                    <div class="ui threaded comments" style="max-width: 100%;">
                        <h3 class="ui dividing header">评论</h3>
                        <div class="comment" th:each="comment:${comments}">
                            <a class="avatar">
                                <img src="../static/images/avatar.png" th:src="@{${comment.img}}">
                            </a>
                            <div class="content">
                                <a class="author">
                                    <span th:text="${comment.nickname}">Matt</span>
                                    <div class="ui mini basic left pointing label m-padded-mini"
                                         th:classappend="${comment.adminComment} ? 'red':'red'"
                                         th:text="${comment.adminComment} ? '博主':'游客' ">博主
                                    </div>
                                </a>
                                <div class="metadata">
                                    <span class="date"
                                          th:text="${#dates.format(comment.createTime,'yyyy-MM-dd HH:mm:ss')}">Today at 5:42PM</span>
                                </div>
                                <div class="text" th:text="${comment.content}">
                                    How artistic!
                                </div>
                                <div class="actions">
                                    <a class="reply" data-commentid="1"
                                       th:attr="data-commentid=${comment.commentsId},data-commentnickname=${comment.nickname}"
                                       data-commentnickname="Matt" onclick="reply(this)">回复</a>
                                    <a class="delete" href="#" onclick="return confirm('确定要删除该评论吗？三思啊! 删了可就没了！')">删除</a>

                                </div>
                            </div>
                            <!--              子集评论-->
                            <div class="comments" th:if="${#arrays.length(comment.replyComments)}>0">
                                <div class="comment" th:each="reply:${comment.replyComments}">
                                    <a class="avatar">
                                        <img src="../static/images/avatar.png" th:src="@{${reply.img}}">
                                    </a>
                                    <div class="content">
                                        <a class="author">
                                            <span th:text="${reply.nickname}">小红</span>
                                            <div class="ui mini basic left pointing label m-padded-mini"
                                                 th:classappend="${reply.adminComment} ? 'red':'red'"
                                                 th:text="${reply.adminComment} ? '博主':'游客'">博主
                                            </div>
                                            &nbsp;<span class="m-red" th:text="|@ ${reply.parentNickname}|">@ 小白</span>
                                        </a>
                                        <div class="metadata">
                                            <span class="date"
                                                  th:text="${#dates.format(reply.createTime,'yyyy-MM-dd HH:mm:ss')}">Today at 5:42PM</span>
                                        </div>
                                        <div class="text" th:text="${reply.content}">
                                            How artistic!
                                        </div>
                                        <div class="actions">
                                            <a class="reply" data-commentid="1"
                                               th:attr="data-commentid=${reply.commentsId},data-commentnickname=${reply.nickname}"
                                               data-commentnickname="Matt" onclick="reply(this)">回复</a>
                                            <a class="delete" href="#" onclick="return confirm('确定要删除该评论吗？三思!')">删除</a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
            <div th:if="${blog.commentOpen}">
                <div id="comment-form" class="ui form" >
                    <!--        在那个博客下面评论的-->
                    <input type="hidden" name="blogId" th:value="${blog.blogId}">
    <!--                <input type="hidden" name="heroId"th:if="${hero!=null and hero.commentOpen}" th:value="${hero?.heroId==null?0:hero?.heroId}">-->
                    <!--        需要知道父级的评论集合-->
                    <input type="hidden" name="parentCommentsId" value="-1">
                    <div class="field">
                        <textarea name="content" placeholder="请输入评论信息..."></textarea>
                    </div>
                    <div class="fields">
                        <div class="field m-mobile-wide m-margin-bottom-small">
                            <div class="ui left icon input">
                                <i class="user icon"></i>
                                <input type="text" name="nickname" placeholder="姓名">
                            </div>
                        </div>
                        <div class="field m-mobile-wide m-margin-bottom-small">
                            <div class="ui left icon input">
                                <i class="mail icon"></i>
                                <input type="text" name="email" placeholder="邮箱">
                            </div>
                        </div>
                        <div class="field  m-margin-bottom-small m-mobile-wide">
                            <button id="commentpost-btn" type="button" class="ui red button m-mobile-wide"><i
                                    class="edit icon"></i>发布
                            </button>
                        </div>
                    </div>

                </div>
            </div>
        </div>

    </div>
</div>


<!--目录显示-->
<div id="toolbar" class="m-padded m-fixed m-right-bottom" style="display: none">
    <div class="ui vertical icon buttons ">
        <button type="button" class="ui toc red button">目录</button>
        <a href="#comment-container" class="ui red button">评论</a>
        <div id="toTop-button" class="ui icon button"><i class="chevron up icon"></i></div>
    </div>
</div>


<div class="ui toc-container flowing popup transition hidden" style="width: 250px!important;">
    <ol class="js-toc">

    </ol>
</div>

<div id="qrcode" class="ui wechat-qr flowing popup transition hidden " style="width: 130px !important;">
    <!--<img src="./static/images/wechat.jpg" alt="" class="ui rounded image" style="width: 120px !important;">-->
</div>


<br>
<br><br>
<br><br>

<!--    抽取公共footer    -->
<div th:replace="share/common :: #footer"></div>


<!--    抽取公共js    -->
<div th:replace="share/common :: #js"></div>
<!--<script th:inline="javascript">-->
<!--    var blog=[[${blog}]];-->
<!--    console.log(blog);-->
<!--</script>-->

<script>

    // function myfunction(){
    //   $("#comment-container").load("\/comments\/65");
    // }

    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    });

    $('#payButton').popup({
        popup: $('.payQR.popup'),
        on: 'click',
        position: 'bottom center'
    });

    tocbot.init({
        // Where to render the table of contents.
        tocSelector: '.js-toc',
        // Where to grab the headings to build the table of contents.
        contentSelector: '.js-toc-content',
        // Which headings to grab inside of the contentSelector element.
        headingSelector: 'h1, h2, h3',
    });

    $('.toc.button').popup({
        popup: $('.toc-container.popup'),
        on: 'click',
        position: 'left center'
    });

    $('.wechat').popup({
        popup: $('.wechat-qr'),
        position: 'left center'
    });

    //置顶图标和工具栏内容
    $('#toTop-button').click(function () {
        $(window).scrollTo(0, 500);
    });
    var waypoint = new Waypoint({
        element: document.getElementById('waypoint'),
        handler: function (direction) {
            if (direction == 'down') {
                $('#toolbar').show(100);
            } else {
                $('#toolbar').hide(500);
            }
            console.log('Scrolled to waypoint!  ' + direction);
        }
    })

    var serurl = "??blog.serurl_zh_CN??";
    var url = "\/blog\/65";
    var qrcode = new QRCode("qrcode", {
        text: serurl + url,
        width: 110,
        height: 110,
        colorDark: "#000000",
        colorLight: "#ffffff",
        correctLevel: QRCode.CorrectLevel.H
    });


    //评论表单验证
    $('.ui.form').form({
        fields: {
            content: {
                identifier: 'content',
                rules: [{
                    type: 'empty',
                    prompt: '请输入评论内容'
                }
                ]
            },
            nickname: {
                identifier: 'nickname',
                rules: [{
                    type: 'empty',
                    prompt: '请输入你的大名'
                }]
            },
            email: {
                identifier: 'email',
                rules: [{
                    type: 'email',
                    prompt: '请填写正确的邮箱地址'
                }]
            }
        }
    });


    //初始化 一开始底下就显示评论
    $(function () {
        if ([[${blog!=null}]]) {
            console.log('blog')
            $("#comment-container").load("[[@{/comments/{blogId}(blogId=${blog?.blogId})}]]");
        }
        // else
        //     if ([[${hero!=null}]]) {
        //     console.log('hero')
        //     $("#comment-container").load("[[@{/heroComments/{heroId}(heroId=${hero?.heroId})}]]");
        // }
    });


    //发布按钮校验过程
    $('#commentpost-btn').click(function () {
        var boo = $('.ui.form').form('validate form');
        if (boo) {
            console.log('校验成功');
            postData();
        } else {
            console.log('校验失败');
        }
    });

    //这是发送请求的函数
    function postData() {
        if ([[${blog!=null}]]) {
            $("#comment-container").load("\/comments", {
                "parentCommentsId": $("[name='parentCommentsId']").val(),
                "blogId": $("[name='blogId']").val(),
                "heroId": $("[name='heroId']").val(),
                "nickname": $("[name='nickname']").val(),
                "email": $("[name='email']").val(),
                "content": $("[name='content']").val()
            }, function (responseTxt, statusTxt, xhr) {
                //发布完之后清空，并且滚动到上方
                // $(window).scrollTo($('#goto'),500);
                clearContent();
            });
        }
        // else {
        //     $("#comment-container").load("\/heroComments", {
        //         "parentCommentsId": $("[name='parentCommentsId']").val(),
        //         "blogId": $("[name='blogId']").val(),
        //         "heroId": $("[name='heroId']").val(),
        //         "nickname": $("[name='nickname']").val(),
        //         "email": $("[name='email']").val(),
        //         "content": $("[name='content']").val()
        //     }, function (responseTxt, statusTxt, xhr) {
        //         //发布完之后清空，并且滚动到上方
        //         // $(window).scrollTo($('#goto'),500);
        //         clearContent();
        //     });
        // }

    }

    //清空下方评论域函数
    function clearContent() {
        $("[name='nickname']").val('');
        $("[name='email']").val('');
        $("[name='content']").val('');
        $("[name='parentCommentsId']").val(-1);
        $("[name='content']").attr("placeholder", "请输入评论信息...");
    }

    //点击回复
    function reply(obj) {
        var commentId = $(obj).data('commentid');
        var commentNickname = $(obj).data('commentnickname');
        $("[name='content']").attr("placeholder", "@" + commentNickname).focus();
        $("[name='parentCommentsId']").val(commentId);
        $(window).scrollTo($('#comment-form'), 500);
    }


</script>
</body>
</html>